﻿using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Windows.Forms;

namespace PefStudio.StartUp
{
    [Export(Contract, typeof(Bootstrapper))]
    public class WinBootstrapper : Bootstrapper
    {
        public const string WindowCatalog = "Win";

        public WinBootstrapper()
        {
            Instance = this;
            Description = "WinBootstrapper";
        }

        public override void Run(bool runWithDefaultConfiguration)
        {
            var catalog = new AggregateCatalog();
            catalog.Catalogs.Add(new DirectoryCatalog(WindowCatalog));

            Container = new CompositionContainer(catalog);
            Container.ComposeParts();

            var form = Container.GetExportedValue<Form>(MainWindowContract);
            Application.Run(form);
        }
    }
}
